package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.ThemeCatalog;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IThemeCatalogService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 礼品主题目录资源控制器
 */
@Controller
@RequestMapping("themeCatalog")
public class ThemeCatalogController {

    @Autowired
    private IThemeCatalogService themeCatalogService;

    /**
     * 列表界面
     * @param qo
     * @param model
     * @return
     */
    @RequestMapping("list")
    public String list(@ModelAttribute("qo") QueryObject qo, Model model){
        model.addAttribute("pageInfo",themeCatalogService.query(qo));
        return "themeCatalog/list";
    }

    /**
     * 新增/修改
     * @param themeCatalog
     * @return
     */
    @RequestMapping("saveOrUpdate")
    @ResponseBody
    public JsonResult saveOrUpdate(ThemeCatalog themeCatalog){
        themeCatalogService.saveOrUpdate(themeCatalog);
        return new JsonResult();
    }

}
